//
//  FCRelationTypeDefaultCell.m
//  FCIM
//
//  Created by 陈文斌 on 2019/6/12.
//

#import "FCRelationTypeDefaultCell.h"
#import "CustomerRelationHeader.h"

@implementation FCRelationTypeDefaultCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        WJCWeakSelf
        UIImageView *arrowImage = [UIImageView new];
        [self.contentView addSubview:arrowImage];
        [arrowImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-16);
            make.centerY.mas_equalTo(0);
            make.width.and.height.mas_equalTo(16);
        }];
        arrowImage.image = customerRelationImageName(@"ic_arrow_left");
        
        self.detailLabel = [UILabel new];
        [self.contentView addSubview:self.detailLabel];
        [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(arrowImage.mas_left).mas_equalTo(16);
            make.centerY.mas_equalTo(0);
        }];
        self.detailLabel.font = font12;
        self.detailLabel.textColor = FCGrayTxtPlaceColor;
        self.detailLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        
        self.titleLabel = [UILabel new];
        [self.contentView addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(16);
            make.centerY.mas_equalTo(0);
            make.right.equalTo(weakSelf.detailLabel.mas_left).mas_equalTo(-8);
            make.width.lessThanOrEqualTo(@(weakSelf.contentView.width / 2)).priorityHigh();
        }];
        self.titleLabel.font = font16;
        self.titleLabel.textColor = FCTxtColor;
        self.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        
        UIView *lineView = [UIView new];
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.bottom.mas_equalTo(0);
            make.height.mas_equalTo(0.5);
        }];
        lineView.backgroundColor = FCLineColor;
    }
    
    return self;
}

- (void)setDataWithRelationTypeName:(NSString *)typeName andEmplyeeName:(NSString *)employeeName{
    self.titleLabel.text = typeName;
    if (employeeName.length > 0) {
        self.detailLabel.textColor = FCGrayTxtPlaceColor;
        self.detailLabel.text = [NSString stringWithFormat:@"负责人：%@", employeeName];
    } else{
        self.detailLabel.textColor = FCOrangeTextColor;
        self.detailLabel.text = @"授权负责人";
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
